package com.qyer.lxp.common.file;

import com.qyer.lxp.common.framework.util.QyerConfig;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by wangzhen on 3/6/16.
 */
public class ProductCodeList {
    private static String code_file = QyerConfig.getInstance().getString("qyer.product.codelist");

    private static ProductCodeList instance;

    /**
     * 存储选好的商品code
     */
    private static List<String> list_code = new ArrayList<String>();

    public static ProductCodeList getInstance(){
        if(null==instance){
            instance=new ProductCodeList();
        }
        return instance;
    }


    public List<String> getProductCodeList(){
        System.out.println("初始化内存");
        try {
            BufferedReader reader = new BufferedReader(new FileReader(code_file));
            String line;
            while ((line = reader.readLine()) != null) {
                list_code.add(line);

            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return list_code;
    }
}
